package com.xckj.teacher.ui.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.xckj.teacher.R;
import com.xckj.teacher.databinding.ActivityBrowserBinding;
import com.xckj.teacher.framework.BaseActivity;
import com.xckj.teacher.global.Constant;

/**
 * @Author: ChenYao
 * @Describe: 浏览器页面
 * @Date: 2024/6/7 20:36
 */
public class BrowserActivity extends BaseActivity<ActivityBrowserBinding> {

    private String h5UrlPath;

    public static void start(Context context, String urlPath) {
        context.startActivity(new Intent(context, BrowserActivity.class).putExtra(Constant.H5_URL_PATH, urlPath));
    }

    @Override
    protected int setStatusBarColor() {
        return R.color.color_f7f8fa;
    }

    @Override
    protected int loadLayout() {
        return R.layout.activity_browser;
    }

    @Override
    protected void initData() {
        h5UrlPath = getIntent().getStringExtra(Constant.H5_URL_PATH);
        initWebView();
    }

    @SuppressLint("SetJavaScriptEnabled")
    private void initWebView() {
        dataBinding.webView.setHorizontalScrollBarEnabled(false);
        dataBinding.webView.loadUrl(h5UrlPath);
    }

    @Override
    protected void setListener() {

    }

    @Override
    public void onBackPressed() {
        if (dataBinding.webView.goBack()) {
            return;
        }
        super.onBackPressed();
    }

}
